package be.colwri.client;

import java.io.Serializable;

public abstract class Command implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1147503485423491498L;
	/**
	 * 
	 */
	
	String zin;
	
	 Command() {
		
	}
	 public abstract void doorstuurCommand (Command cmnd);
	 public abstract int getPosition();
	 protected abstract void setPosition(int pos);
	 public abstract String execute(String execstr);
  
	 /**
		 * The command ac precedes this Command in the CP
		 * and is a Command that has not been handled yet by the Client creating this Command
		 * 
		 * @param ac
		 * 
		 */
		public void recalculateCommand(AddCommand ac) {
			//Smaller or equal because of getting further!
			if (ac.getPosition() <= getPosition()) {
				setPosition(getPosition() + ac.getTyped().length());
			}
		}
		
		
		
		public void recalculateCommand(RemoveCommand ac) {
			if (ac.getPosition() <= getPosition()) {
				setPosition(getPosition() - ac.getLength());
			}
		}
  
  public String getZin()  {
	  return zin;
  }

  
}
